class User:
    def __init__(self, *args, **kwargs):
        # 定义一个字典，包含所有有效的属性名
        valid_fields = {'id': None, 'username': None, 'password': None, 'nickname': None, 'email': None, 'phone': None,
                        'avatarPath': None}

        # 首先处理关键字参数
        for key, value in kwargs.items():
            if key in valid_fields:
                valid_fields[key] = value

        # 如果还传入了位置参数（元组），则假设它们按顺序对应valid_fields的键
        if args:
            if len(args) != len(valid_fields):
                raise ValueError("Number of positional arguments does not match the number of valid fields.")
            for key, value in zip(valid_fields.keys(), args):
                valid_fields[key] = value

         # 将valid_fields中的值设置为类的属性
        for key, value in valid_fields.items():
            setattr(self, key, value)

    def get_avatar_path(self):
        return self.avatarPath

    def to_dict(self):
        # 创建一个只包含valid_fields中定义字段的字典
        return {key: getattr(self, key, self.valid_fields[key]) for key in self.valid_fields}


def __str__(self):
        return f"User ID: {self.id}, username: {self.username}, Password: {self.password}, Nickname: {self.nickname}, Email: {self.email}, Phone: {self.phone}, Avatar Path: {self.avatarPath}"
